package com.rs.service.impl.rs;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rs.dao.NoticeMapper;
import com.rs.model.CommonResult;
import com.rs.model.Notice;
import com.rs.service.rs.NoticeService;
import com.rs.util.TimeTypeConversionUtil;

/**
 * 通知
 * @author HuJie
 *
 */

@Service
public class NoticeServiceImpl implements NoticeService {

	@Autowired
	private NoticeMapper nd;

	//查询所有通知
	@Override
	public CommonResult<Map<String, Object>> noticeAllPC(Notice notice) {
		Page<Notice> page = PageHelper.startPage(notice.getPageNum(), 10);
		List<Notice> list = nd.noticeAllPC(notice);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", list);
		map.put("total", page.getTotal());
		map.put("pageNum", page.getPageNum());
		map.put("pages", page.getPages());
		return new CommonResult<Map<String, Object>>(200, "查询成功", map);
	}

	//根据ID查询
	@Override
	public Notice noticeByTjPC(Integer id) {
		return nd.noticeByTjPC(id);
	}

	//修改通知
	@Override
	public int noticeUpdatePC(Notice notice) {
		notice.setNo_time(TimeTypeConversionUtil.getStringDate(new Date()));
		return nd.noticeUpdatePC(notice);
	}

	//添加通知
	@Override
	public int noticAdd(Notice notice) {
		notice.setNo_time(TimeTypeConversionUtil.getStringDate(new Date()));
		return nd.noticAdd(notice);
	}

	//删除通知
	@Override
	public int noticeDeletePC(Integer id) {

		return nd.noticeDeletePC(id);
	}

	//App查询
	@Override
	public List<Notice> NoticApp() {

		return nd.NoticApp();
	}
}
